import cv2 as cv
import face_recognition
import numpy as np

img = cv.imread('1.jpg')
img2 = cv.imread('1.jpg')

face_locations = face_recognition.face_locations(img)

face_encodings = face_recognition.face_encodings(img, face_locations)[0]
face_encodings2 = face_recognition.face_encodings(img2, face_locations)[0]

#计算欧几里得距离，小于0.5则认为是同一张脸
distance1 = np.linalg.norm(face_encodings - face_encodings2)